package com.peanut.mapper;

import com.orm.annotation.Delete;
import com.orm.annotation.Insert;
import com.orm.annotation.Select;
import com.orm.mapper.BaseMapper;
import com.peanut.entity.Menu;
import com.peanut.entity.vo.MenuTreeVo;

import java.util.List;

public interface MenuMapper extends BaseMapper<Menu> {
	
	@Insert("insert into menu values(null,#{menu.menuName},#{parentId},#{isShow},#{iconClassName},#{menu_url})")
	void addMenu(Menu menu);
	
	@Delete("delete from menu where id = #{id} ")
	void deleteMenu(int id);
	
	// 动态条件
	void updateMenu(Menu menu);
	
	
	@Select("select id,menu_name,parent_id,is_show,icon_class_name,menu_url from menu")
	List<Menu> queryAll();
	
	@Select("select id,menu_name,parent_id,is_show,icon_class_name,menu_url from menu where parent_id = 0")
	List<MenuTreeVo> queryAllTopMenu();
	
	@Select("select id,menu_name,parent_id,is_show,icon_class_name,menu_url from menu where parent_id != 0")
	List<Menu> queryAllSonMenu();
	
	
	
	
}
